﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebStudio.Business.Rule;
using WebStudio.Business.Entity;

public partial class Detail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            loadData();
        }
    }

    private void loadData()
    {
        if (articalEntity == null)
        {
            //ApplicationHelper.AddScriptBlock(this, "alert('该页面不存在');window.location.href='Default.aspx'");
            Response.Redirect("~/Default.aspx");
        }
        else
        {
            AddHits();
        }
    }

    public ArticalEntity articalEntity
    {
        get
        {
            if (string.IsNullOrEmpty(Request.QueryString["id"]))
            {
                return null;
            }
            else
            {
                try
                {
                    int aid = Convert.ToInt32(Request.QueryString["id"]);
                    return ArticalRule.GetDeepArticalEntity(aid);
                }
                catch
                {
                    return null;
                }
            }
        }
    }

    private void AddHits()
    {
        if (articalEntity != null)
        {
            ArticalEntity info = new ArticalEntity();
            info = articalEntity;
            info.ArticalHits = articalEntity.ArticalHits + 1;
            ArticalRule.SaveArticalInfor(info);
        }
    }
    //public CategoryEntity categoryEntity
    //{
    //    get
    //    {
    //        if (articalEntity == null)
    //        {
    //            return null;
    //        }
    //        else
    //        {
    //            return CategoryRule.GetDeepCategoryEntity(articalEntity.CategoryInfo.CategoryId);
    //        }
    //    }
    //}

    //public string PCategroyNav()
    //{
    //    string strCategoryNav = "";
    //    int PId=categoryEntity.CategoryInfo.CategoryId;
    //    int CId = categoryEntity.CategoryId;
    //    string CName = categoryEntity.CategoryName;
    //    if (PId.Equals(1))
    //    {
    //        strCategoryNav += "<a href=\"NewsList.aspx\">公司动态</a>";
    //    }
    //    if (PId.Equals(2))
    //    {
    //        strCategoryNav += "<a href=\"ProductList.aspx\">服务项目</a> > <a href=\"ProductList.aspx?cid=" + CId + "\">" + CName + "</a>";
    //    }
    //    if (PId.Equals(3))
    //    {
    //        strCategoryNav += "<a href=\"CaseList.aspx\">成功案例</a>";
    //    }
    //    return strCategoryNav;
    //}
}
